A walkthrough of Ernest (2005)’s original analytical approach, from close reading of the paper.
Ernest drew data from the Andrews LTER, the Sevilleta, Niwot Ridge, and Portal.
The data available online do not quite match the descriptive statistics reported in Ernest (2005).
replicate-becsDownload raw data. By default data will be stored in subdirectories of replicate-becs/data/paper/raw/ for each site.
download_raw_paper_data()
Process raw data into the appropriate format. This is a data table with a record for each individual and columns for species and weight in grams. By default these tables will be stored in subdirectores of replicate-becs/data/paper/processed.
process_raw_data()
Loading in data version 1.106.0
[1] TRUE
Load data tables for each community. There should be 9 communities.
communities <- load_paper_data()
length(communities)
[1] 9
Each community should be a data table with columns for species and size for each individual, for example:
names(communities)
[1] "andrews" "niwot" "portal"
[4] "sev-5pgrass" "sev-5plarrea" "sev-goatdraw"
[7] "sev-rsgrass" "sev-rslarrea" "sev-two22"
head(communities[[1]])
replicate-becsFor every individual, calculate metabolic rate and assign to a size class.
communities_energy <- lapply(communities, FUN = make_community_table, ln_units = 0.2)
head(communities_energy[[1]])
For each community, sum total energy use for each size class, and convert to the proportion of total energy use for that community.
bseds <- lapply(communities_energy, FUN = make_bsed)
head(bseds[[1]])
replicate-becsCalculate mean mass of each species in each community.
bsds <- lapply(communities, FUN = make_bsd)
head(bsds[[1]])
replicate-becsenergetic_dom <- lapply(communities_energy, FUN = energetic_dominance)
head(energetic_dom[[1]])
energetic_dom_prop <- lapply(communities_energy, FUN = energetic_dominance, mode_cutoff = 'prop')
replicate-becsbsed_uniform_bootstraps <- lapply(communities, FUN = community_bootstrap, bootstrap_function = 'bootstrap_unif_bsed_doi', nbootstraps = 10)
See issue #4 on github.
replicate-becscommunity_combination_indices = utils::combn(x = c(1:9), m = 2, simplify = TRUE) %>%
t() %>%
as.data.frame() %>%
dplyr::rename(community_a = V1, community_b = V2)
combine_communities = function(indices, communities) {
community_combination = list(community_a = communities[[indices[1]]], community_b = communities[[indices[2]]], community_names = c(names(communities)[[indices[1]]], names(communities)[[indices[2]]]))
return(community_combination)
}
community_combinations = apply(community_combination_indices, MARGIN = 1, FUN = combine_communities, communities = communities)
bsed_crosscomm_bootstraps = lapply(community_combinations, FUN = community_bootstrap,
bootstrap_function = 'bootstrap_crosscomm_bseds', nbootstraps = 10)
See histogram of p values for comparisons to see if commuities’ BSEDs are the same or different.
ernest_results = read.csv(paste0(here::here(), '/data/ernest_bsd_results.csv'))
print(ernest_results)
replicate-becs:From Zar (1999) Biostatistical Analysis.
Tables of critical values were entered by hand from the appendix to Zar (1999).
bsd_ks_test = lapply(bsds, FUN = zar_ks_test, delta_correction = T,
focal_column = 'species_mean_mass',
expected_range = NULL,
n_or_i = 'n')
print(bsd_ks_test)
$andrews
$andrews$signif
[1] TRUE
$andrews$p_max
[1] 0.02
$andrews$p_min
[1] 0
$andrews$d
[1] 0.4824239
$niwot
$niwot$signif
[1] TRUE
$niwot$p_max
[1] 0.02
$niwot$p_min
[1] 0
$niwot$d
[1] 0.6140682
$portal
$portal$signif
[1] TRUE
$portal$p_max
[1] 0.02
$portal$p_min
[1] 0
$portal$d
[1] 0.4946621
$`sev-5pgrass`
$`sev-5pgrass`$signif
[1] TRUE
$`sev-5pgrass`$p_max
[1] 0.02
$`sev-5pgrass`$p_min
[1] 0
$`sev-5pgrass`$d
[1] 0.3893173
$`sev-5plarrea`
$`sev-5plarrea`$signif
[1] TRUE
$`sev-5plarrea`$p_max
[1] 0.02
$`sev-5plarrea`$p_min
[1] 0
$`sev-5plarrea`$d
[1] 0.462416
$`sev-goatdraw`
$`sev-goatdraw`$signif
[1] TRUE
$`sev-goatdraw`$p_max
[1] 0.02
$`sev-goatdraw`$p_min
[1] 0
$`sev-goatdraw`$d
[1] 0.3881576
$`sev-rsgrass`
$`sev-rsgrass`$signif
[1] TRUE
$`sev-rsgrass`$p_max
[1] 0.02
$`sev-rsgrass`$p_min
[1] 0
$`sev-rsgrass`$d
[1] 0.4672033
$`sev-rslarrea`
$`sev-rslarrea`$signif
[1] TRUE
$`sev-rslarrea`$p_max
[1] 0.02
$`sev-rslarrea`$p_min
[1] 0
$`sev-rslarrea`$d
[1] 0.4343417
$`sev-two22`
$`sev-two22`$signif
[1] TRUE
$`sev-two22`$p_max
[1] 0.02
$`sev-two22`$p_min
[1] 0
$`sev-two22`$d
[1] 0.5084637
The \(\delta\) corrected KS test does not correspond to the results from Ernest when the species mean body size values are on an untransformed scale.
Using the natural log of the species mean body size value, however…:
bsd_ks_test_log = lapply(bsds, FUN = zar_ks_test, delta_correction = T,
focal_column = 'ln_mass',
expected_range = NULL,
n_or_i = 'n')
print(bsd_ks_test_log)
$andrews
$andrews$signif
[1] FALSE
$andrews$p_max
[1] 1
$andrews$p_min
[1] 0.5
$andrews$d
[1] 0.1398433
$niwot
$niwot$signif
[1] FALSE
$niwot$p_max
[1] 0.5
$niwot$p_min
[1] 0.1
$niwot$d
[1] 0.2973462
$portal
$portal$signif
[1] FALSE
$portal$p_max
[1] 1
$portal$p_min
[1] 0.5
$portal$d
[1] 0.1436705
$`sev-5pgrass`
$`sev-5pgrass`$signif
[1] FALSE
$`sev-5pgrass`$p_max
[1] 1
$`sev-5pgrass`$p_min
[1] 0.5
$`sev-5pgrass`$d
[1] 0.1252882
$`sev-5plarrea`
$`sev-5plarrea`$signif
[1] FALSE
$`sev-5plarrea`$p_max
[1] 0.5
$`sev-5plarrea`$p_min
[1] 0.1
$`sev-5plarrea`$d
[1] 0.2037134
$`sev-goatdraw`
$`sev-goatdraw`$signif
[1] FALSE
$`sev-goatdraw`$p_max
[1] 1
$`sev-goatdraw`$p_min
[1] 0.5
$`sev-goatdraw`$d
[1] 0.1327084
$`sev-rsgrass`
$`sev-rsgrass`$signif
[1] FALSE
$`sev-rsgrass`$p_max
[1] 1
$`sev-rsgrass`$p_min
[1] 0.5
$`sev-rsgrass`$d
[1] 0.1617653
$`sev-rslarrea`
$`sev-rslarrea`$signif
[1] FALSE
$`sev-rslarrea`$p_max
[1] 1
$`sev-rslarrea`$p_min
[1] 0.5
$`sev-rslarrea`$d
[1] 0.1415647
$`sev-two22`
$`sev-two22`$signif
[1] FALSE
$`sev-two22`$p_max
[1] 1
$`sev-two22`$p_min
[1] 0.5
$`sev-two22`$d
[1] 0.1663774
With mean mass logged, all the results replicate qualitatively (i.e. not significantly different from uniform) and Niwot, for which the currently-available data most closely matches that reported in Ernest (2005), replicates almost exactly numerically.
Ernest (2005) used a two-sample Kolmogorov-Smirnov test to compare every possible combination of community-level BSDs.
replicate-becs